﻿/*********************************************
* 命名空间: DataCode.DatabaseDrives.PostgreSqlProvide
* 功 能： abp连接PostgreSQL数据库模块
* 类 名： PostgreSqlModule
* 作 者:  东腾
* 时 间： 2018/2/24 16:02:59 
**********************************************
*/
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Abp.Configuration.Startup;
using Abp.Modules;
using Abp.NHibernate;
using FluentNHibernate.Cfg.Db;

namespace DataCode.DatabaseDrives.PostgreSqlProvide
{
    [DependsOn(typeof(AbpNHibernateModule))]
    public class PostgreSqlModule : AbpModule
    {
        //重写PreInitialize方法
        public override void PreInitialize()
        {
            var pgStr = ConfigurationManager.ConnectionStrings["PostgreSql"].ConnectionString;

            var config = Configuration.Modules.AbpNHibernate().FluentConfiguration
                .Database(PostgreSQLConfiguration.Standard.ConnectionString(pgStr));
            //映射配置
            config.Mappings(a => a.FluentMappings.AddFromAssembly(Assembly.GetExecutingAssembly()));
        }
        //重写Initialize方法
        public override void Initialize()
        {
            IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
        }
    }

}
